<?php

namespace app\index\controller\formdesign;

use addons\formdesign\library\FormDesignApi;
use addons\formdesign\library\Formsafe;
use app\common\controller\Frontend;

class Foreign extends Frontend
{

    /**
     * Foreign模型对象
     * @var \app\admin\model\form\Index
     */
    protected $noNeedLogin = ['index']; //无需登录的方法,同时也就不需要鉴权了
    protected $noNeedRight = []; //无需鉴权的方法,但需要登录
    public function _initialize()
    {
        parent::_initialize();
        Formsafe::safe_gpc();
    }
    public function index()
    {
        $this->request->filter(['strip_tags']);
        $form_id = $this->request->param('form_id');
        $FormDesign = new FormDesignApi($form_id);
        if ($this->request->isAjax()) {
            $FormDesign->setData($this->request->post());
        }
        $this->assign('form', $FormDesign->add()->getForm());
        $this->view->engine->layout('layout/default');
        return $this->view->fetch();
    }
}
